package top.yxqz.servletconfig;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Mr.余
 * @date 2022/11/10
 * @package top.yxqz.servletconfig
 */
public class ServletConfigDemo1 extends HttpServlet {
    String coding = null;
    @Override
    public void init(ServletConfig config) throws ServletException {
        String name = config.getInitParameter("name");
        System.out.println("init-param标签中获取的信息："+name);
        coding =  config.getInitParameter("coding");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding(coding);
        System.out.println("coding编码格式："+coding);
    }
}
